package com.insightfullogic.java8.examples.chapter9.vertx;/*
package com.insightfullogic.java8.examples.chapter9.vertx;

import io.vertx.core.Handler;
import io.vertx.core.buffer.Buffer;
import io.vertx.rxjava.core.Vertx;
import io.vertx.rxjava.core.eventbus.EventBus;
import io.vertx.rxjava.core.net.NetSocket;
import org.vertx.java.platform.Verticle;

import java.util.Optional;
import java.util.Set;
import java.util.regex.Pattern;

*/
/**
 * @author lili
 * @description ${DESCRIPTION}
 * @create 2018-01-20 下午4:58
 * @since
 **//*

public class User implements Handler<Buffer> {
    private static final Pattern newline = Pattern.compile("\\n");
    private final NetSocket socket;
    private final Set<String> names;
    private final EventBus eventBus;
    private Optional<String> name;

    public User(NetSocket socket, Verticle verticle) {
        Vertx vertx = verticle.getVertx();
        this.socket = socket;
        names = vertx.sharedData().getSet("names");
        eventBus = vertx.eventBus();
        name = Optional.empty();
    }

    @Override
    public void handle(Buffer buffer) {

        newline.splitAsStream(buffer.toString())
            .forEach(line -> {
                if (name.isPresent()) {
                    setName(line);
                } else {
                    handle(line);
                } });
    }
}
*/
